<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		
<script language="JavaScript">

//while循环

   var i=1;
   var sum=i;
   document.write("累加和不大于10的所有自然数为:<br>");
   while(sum<=10){
   	sum=sum+i;
   	document.write(i+'<br />');
   	i++;
   	
   	
   }
	
//for循环
var sum=0;
for(i=1;i<100;i+=2){
	sum=sum+i;
}
alert("100以内所有奇数的和为："+sum);


	
</script>
		
		
	</body>
</html>
